import { Product } from './../../product/entities/product.entity';
import { ApiProperty } from '@nestjs/swagger';
import { Base } from 'src/entities/Base';
import { Entity, Column, OneToOne, JoinColumn, ManyToOne } from 'typeorm';

@Entity('stock_record')
export class Stock extends Base {
    @ApiProperty()
    @Column({ name: 'type', type: 'int', comment: '0:入库1:出库', default: 0 })
    type: number;

    typeDesc: string;

    @Column({
        name: 'order_date',
        type: 'timestamp',
        default: () => 'CURRENT_TIMESTAMP',
        nullable: true,
        comment: '入库日期/出库日期',
    })
    orderDate: Date;

    @ApiProperty()
    @Column({ name: 'guid', comment: '唯一ID', default: '' })
    guid: string;

    @ApiProperty()
    @Column({ name: 'creator_guid', comment: '创建人ID', default: '' })
    creatorGuid: string;

    @ApiProperty()
    @Column({ name: 'p_id', comment: '商品ID', default: '' })
    pId: string;

    @ApiProperty()
    @Column({ name: 'price', type: 'decimal', comment: '单价', default: 0, precision: 10, scale: 2 })
    price: number;

    @ApiProperty()
    @Column({ comment: '数量', default: 0 })
    total: number;

    @ApiProperty()
    @Column({ name: 'sum', type: 'decimal', comment: '总价', default: 0, precision: 10, scale: 2 })
    sum: number;

    @ApiProperty()
    @Column({ name: 'postage', type: 'decimal', comment: '邮费', default: 0, precision: 10, scale: 2 })
    postage: number;

    product: Product;
}
